Thread: First time using pointers, and i feel lost :|

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2018
    Posts
    11

    First time using pointers, and i feel lost :|

    It's me again, trying to figure out how to use pointers,
    Im supposed to calculate alpha, beta and the lenght of c of a trianlge using a function (triangle_1)
    and from what i think i'll have to use *pointers to get the values out of the function.
    i tested the *cc, *alpha and *beta calculations outside a function and they seem to work

    Code:
    #include <stdio.h>#include <math.h>
    #define TOTAL_DEG  (180.0)
    
    
    void triangle_1 (double a, double b,double c, double gamma, double *cc, double *alpha, double *beta)
        {
            
            *cc= sqrt((a*a+b*b-(2*a*b*cos(gamma))));
            *alpha =(gamma)*(acos((double)(b*b +(c)*(c)- a*a)/(2.0*b*c)));
            *beta = -gamma-*alpha+TOTAL_DEG;
            
        }    
            
            
    int main()
    {
        double a,b,c,gamma,alpha,beta,result;
        double tri;
        printf("Bitte gib a, b und gamma eines Dreiecks ein\n");
        scanf("%lf,%lf,%lf",&a,&b,&gamma);
        prinf("a,b,c: %lf %lf %lf; gegenueber liegende Winkel: %lf %lf %lf",a,b,c,*alpha,*beta,gamma);
        
        return 0;
        
        
    }
        
        
    }

    thanks for the help o/


    *edit, im unsure if im missing these to get the rad to degree or the other way around, i always hated trigonometry
    double rad (double grad) {return (grad/45.) * atan(1.);}
    double grad (double rad) {return (rad*45.) / atan(1.);}
    Last edited by Lyrockzz; 11-21-2018 at 06:17 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lost in structures and pointers
    By shallowbay in forum C Programming
    Replies: 7
    Last Post: 05-30-2013, 11:43 PM
  2. I feel like a stupid, pointers:
    By blunt in forum C++ Programming
    Replies: 2
    Last Post: 05-17-2012, 11:08 AM
  3. hel plz im lost on pointers
    By padizzel in forum C Programming
    Replies: 3
    Last Post: 02-28-2011, 12:05 AM
  4. A little lost and confused with my pointers :/
    By FoxeySoulSLayer in forum C++ Programming
    Replies: 6
    Last Post: 05-01-2009, 01:32 PM
  5. lost time
    By iain in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-21-2001, 10:05 AM

Tags for this Thread